{% if user.is_authenticated %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="/static/favicon.ico">
    <meta name="description" content="">
    <meta name="keyword" content="">
    <meta name="author" content="root" >
    <title>POC扫描模块</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/style.css">
</head>
<body>
{% include 'header.html'%}
{% include 'js.html' %}

<div class="container text-center banner">

	<div class="modal fade" tabindex="-1" role="dialog" id="modal">
	  <div class="modal-dialog" role="document">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<h4 class="modal-title">Modal title</h4>
		  </div>
		  <div class="modal-body">
			<p>One fine body&hellip;</p>
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			<button type="button" class="btn btn-primary">Save changes</button>
		  </div>
		</div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	
	
<div class="row">
<!-- <p>title</p> -->

<div class="text-center banner">
  <h1>Testing: {% for v in poc %} {{ v.name }} {% endfor %}</h1>
  <div class="form-inline"> 

  <p><input autocomplete="on" class="form-control input-lg center-block" type="text" placeholder="http://locaohost:80" style="width: 50%" autocomplete="on" name="url" id="url">
  <input type="hidden" name="id" id="id" value="{% for v in poc %} {{ v.vulID }} {% endfor %}"> 
     <a class="btn btn-primary btn-lg" onclick=poc_scan({% for v in poc %}{{ v.vulID }}{% endfor %}) role="button">检测一下</a>&nbsp;
  <a target="_blank" id="vulscan_report" class="btn btn-primary btn-lg" role="button" href="{% url 'vulid_report' %}">查看报告</a>
	 <!-- <button type="submit">submit</button> -->
  </p>

  </div>
</div>


<div class="col-md-2"></div>
<div class="col-md-8">
{% for v in poc %}
<div class="table-responsive">
  <table class="table table-hover table-bordered">
  <tbody>
  
  <tr>
  <th>应用名称</th>
  <td>{{ v.appName }}</td>
  </tr>


  <tr>
  <th>风险等级</th>
  <td>{{ v.cvss }}</td>
  </tr>
    
  
  <tr>
  <th>官网连接</th>
  <td>{{ v.appPowerLink }}</td>
  </tr>

  <tr>
  <th>影响版本</th>
  <td>{{ v.appVersion }}</td>
  </tr>

  <tr>
  <th>编写作者</th>
  <td>{{ v.author }}</td>
  </tr>

  <tr>
  <th>创建时间</th>
  <td>{{ v.createDate }}</td>
  </tr>  
  <tr>
  <th>漏洞描述</th>
  <td>{{ v.desc }}</td>
  </tr>

  <tr>
  <th>依赖库</th>
  <td>{{ v.install_requires }}</td>
  </tr>

  <tr>
  <th>英文漏洞名称</th>
  <td>{{ v.name }}</td>
  </tr>

  <tr>
  <th>漏洞来源</th>
  <td>{{ v.references }}</td>
  </tr>  


  <tr>
  <th>漏洞实例</th>
  <td>{{ v.samples }}</td>
  </tr>

  <tr>
  <th>更新时间</th>
  <td>{{ v.updateDate }}</td>
  </tr>

  <tr>
  <th>版本信息</th>
  <td>{{ v.version }}</td>
  </tr>  

  <tr>
  <th>漏洞发布ID</th>
  <td>{{ v.vulID }}</td>
  </tr>

  <tr>
  <th>漏洞类型</th>
  <td>{{ v.vulType }}</td>
  </tr>

  <tr>
  <th>POCSUITE文件名</th>
  <td>{{ v.filename }}</td>
  </tr>  


  
  </tbody>
  </table>
</div>

{% endfor %}
</div>
<div class="col-md-2"></div>
</div>



</div>




</script>

{% include 'footer.html' %}

<script language="javascript">
$(window).load(function() {
  //当鼠标滑入时将div的class换成bg_css
  $('.scan').hover(function(){
    $(this).addClass('bg_css'); 
   },function(){
    //鼠标离开时移除divOver样式
    $(this).removeClass('bg_css');
   }
  );
}); 
//隐藏导出报告按钮
$("#vulscan_report").hide(); 
</script>
<!--
  /**
  //当鼠标滑入时将div的class换成bg_css
  $('.scan').hover(function(){
    $(this).addClass('bg_css'); 
   },function(){
    //鼠标离开时移除divOver样式
    $(this).removeClass('bg_css');
   }
  );
  **/
  -->
  
<script>
/** 抛弃json 解析方式
var List = {{ list_data|safe }};
//alert(List);
var json = eval(List);
$.each( json, function(index,content){
//alert(content.fields.name);
//alert("#"+content.fields.vulType);
//alert(content.fields.name);
$("#"+content.fields.vulType).html("<div class=\"col-sm-6 col-md-4 col-lg-3 scan\"><div id=\"content\"><p><span><a href=\"#\">"+content.fields.appName+"</a><span><span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"><span>            </div>");
});
**/
</script>

<!-- 延迟加载 遮罩层 -->
<div class="modal fade" id="loadingModal">
    <div style="width: 200px;height:20px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px">
        <div class="progress progress-striped active" style="margin-bottom: 0;">
            <div class="progress-bar" style="width: 100%;"></div>
        </div>
        <h5>正在检测...</h5>
    </div>
</div>

<!--ajax发post到poc_scan接口 -->
<script>
function poc_scan(id){
  
  ajax_url = window.location.protocol + '//' + window.location.host + "{% url 'poc_scan' %}?" + "id="+id+"&url=" + $("input[name='url']").val();
  //alert(ajax_url);
  //get poc_scan response
  //显示遮罩层
  $('#loadingModal').modal({backdrop: 'static', keyboard: false});
  $("#loadingModal").modal('show');

  $.ajax({
           url:ajax_url,
           type:"GET",
           success:function(data){//ajax返回的数据
            //alert(data);
			var result = data*1; //弱类型强制转换
			$("#loadingModal").modal('hide'); //隐藏遮罩层
			if (result==1){
				$("#vulscan_report").show();
				alert("存在漏洞");
			}else{
				alert("没有发现漏洞!");
			}
          }
      });  
	  
  }
</script>



</body>
</html>
{% else %}
<script>window.location.href="{% url 'login' %}";</script> 
{% endif %}